<?php

/**
 * Created by PhpStorm.
 * User: Justin
 * Date: 2015/6/24
 * Time: 15:48
 */
namespace Publish\Models;

class ModelBase extends \Phalcon\Mvc\Model
{
    public function initialize()
    {
        $this->setConnectionService("dbPublish");
        $this->useDynamicUpdate(true);
    }

    public static function getDataByFieldWithValue($value, $field = 'id')
    {
        $params = array(
            'conditions' => " {$field} = :{$field}: ",
            'bind'       => array(
                "{$field}" => $value,
            ),
        );
        $result = static::findFirst($params);
        if (is_object($result)) {
            return $result->toArray();
        } else {
            return false;
        }
    }

}
